package com.kuaimacode.kframework.wechatminiapp.controller.rest;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kuaimacode.kframework.mybatis.models.user.User;
import com.kuaimacode.kframework.wechatminiapp.service.UserService;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/rest/user")
public class UserRest  {
	
    @Autowired
    private UserService userService;
	
    @ApiOperation(value = "根据OpenId获取用户")
    @GetMapping("/getUserByOpenId/{openId}")
    public ResponseEntity<?> getUserByOpenId(@PathVariable String openId){
    	
    	User user =userService.selectByOpenId(openId);
    	
        return ResponseEntity.status(HttpStatus.OK).body(user);
    }
	
    @ApiOperation(value = "根据手机号获取用户")
    @GetMapping("/getUserByMobile/{mobile}")
    public ResponseEntity<?> getUserByMobile(@PathVariable String mobile){
    	
    	User user = userService.selectByPhone(mobile);
    	
        return ResponseEntity.status(HttpStatus.OK).body(user);
    }
	
	
}